#include "MidiMessage.h"
MidiMessage MidiMessage::NoteOn(int note, int velocity, int channel, int time) {
	MidiMessage msg;
	msg.cmd = NOTE_ON;
	msg.flip = note;
	msg.velocity = velocity;
	msg.channel = channel;
	msg.time = time;
	return msg;
}

MidiMessage MidiMessage::NoteOff(int note, int velocity, int channel, int time) {
	MidiMessage msg;
	msg.cmd = MIDICMD::NOTE_OFF;
	msg.flip = note;
	msg.velocity = velocity;
	msg.channel = channel;
	msg.time = time;
	return msg;
}

MidiMessage MidiMessage::ProgramChange(int program, int channel) {
	MidiMessage msg;
	msg.cmd = MIDICMD::PROGRAM_CHANGE;
	msg.program = program;
	msg.channel = channel;
	return msg;
}
int MidiMessage::size() {
	int size = 1;
	if (this->time > 0x7f)size++;
	if (this->cmd == MIDICMD::NOTE_ON || this->cmd == MIDICMD::NOTE_OFF) {
		size += 3;
	}
	else
		size += 2;
	return size;
}

